package com
{
	import flash.events.NetStatusEvent;
	import flash.events.SecurityErrorEvent;
	import flash.media.Video;
	import flash.net.NetConnection;
	import flash.net.NetStream;

	import mx.controls.Alert;
	
	public class NetConn
	{
		private var nc:NetConnection;
		private var ns:NetStream;
		private var video:Video;
		
		public function NetConn(url:String)
		{
			this.nc = new NetConnection();
			this.nc.connect(url);	
			this.nc.addEventListener(NetStatusEvent.NET_STATUS, onNetStatus);
			this.nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onSecurityError);
		}
		
		public function onNetStatus(e:NetStatusEvent):void {
			switch(e.info.code) {
				case "NetConnection.Connect.Success":
					break;
				case "NetConnection.Connect.Failed":
					Alert.show("尝试连接失败，服务器有可能挂掉了 ！");
					break;
				case "NetConnection.Connect.Rejected":
					Alert.show("遭到服务器拒绝，原因："+e.info.code);
					break;
				case "NetConnection.Connect.Closed":
					Alert.show("连接关闭");
					break;
			}
		}
		
		private function onSecurityError(e:SecurityErrorEvent):void {
			Alert.show(e.toString());
		}

	}
}